#include "LinearAlgebra.cuh"

__device__ void vector3r_Subtraction(cuVector3r * p0, cuVector3r * p1, cuVector3r * ans) {
	ans->x = p0->x - p1->x;
	ans->y = p0->y - p1->y;
	ans->z = p0->z - p1->z;
}

__device__ cuVector3r vector3r_Subtraction_np(cuVector3r p0, cuVector3r p1) {
	cuVector3r ans;
	ans.x = p0.x - p1.x;
	ans.y = p0.y - p1.y;
	ans.z = p0.z - p1.z;
	return ans;
}

__device__ Real vector3r_norm(cuVector3r * p0) {
	Real d;
	d = sqrt(powf(p0->x, 2.0) + powf(p0->y, 2.0) + powf(p0->z, 2.0));
	return d;
}

__device__ Real vector3r_normalize(cuVector3r * p0) {
	Real d;
	d = sqrt(powf(p0->x, 2.0) + powf(p0->y, 2.0) + powf(p0->z, 2.0));
	p0->x = p0->x / d;
	p0->y = p0->y / d;
	p0->z = p0->z / d;
	return d;
}

__device__ void vector3r_scalar_multiply(cuVector3r *p0, Real m, cuVector3r *res) {
	res->x = p0->x * m;
	res->y = p0->y * m;
	res->z = p0->y * m;
}

__device__ Real vector3r_dot_multiply(cuVector3r *p0, cuVector3r *p1) {
	Real d;
	d = p0->x*p1->x + p0->y * p1->y + p0->z* p1->z;
	return d;
}